home *** CD-ROM | disk | FTP | other *** search
- Path: flash.LakeheadU.Ca!jgvotour
- From: jgvotour@flash.LakeheadU.Ca (Bonestripper/Omni)
- Newsgroups: comp.sys.cbm
- Subject: Re: Scanning strings under BASIC, avoiding INPUT "?"
- Message-ID: <23371@storm.LakeheadU.Ca>
- Date: 1 Apr 1996 15:50:51 GMT
- References: <4jc9kt$h3p@news.rrz.uni-koeln.de>
- Sender: news@storm.LakeheadU.Ca
- Organization: Lakehead University
- X-Newsreader: TIN [version 1.2 PL1]
-
- Joerg Bleimann (a2233495@rrz.Uni-Koeln.DE) wrote:
- : Hi Freaks!
-
- : I have got a problem with COMMODORE BASIC 2.0: I started programming a text
- : adventure on the C 64 and do not know how to make the computer recognize the
- : latter part of a bipartite command string (for example "TAKE BOTTLE"). How
- : can I search the whole string for empties (" ") to redefine the part right
- : from the empty as a new string? ASC only recognizes the first character of a
- : string, VAL takes only number characters into account... and machine language
- : is all Greek to me!
- : Yet another question: in more modern BASIC dialects, one can avoid the ? after
- : INPUT by typing a comma before the variable; in CBM BASIC 2.0 this would pro-
- : duce a SYNTAX ERROR. Are there any ways to get rid of the question mark using
- : BASIC on the C 64?
-
- : See you in Khyberspace!
-
- : Joerg "Yadgar Achakzai" Bleimann
-
- : The Virtual Afghan
-
- To avoid the question mark, you can put a POKE 19,0 before the INPUT command
- and then put a POKE 19,65 afterwards (I think that's the order, if not
- reverse the POKE commands, ie. POKE 19,65:INPUT...:POKE19,0). Unfortunately,
- this plays with the computer a little bit....
- For the ohter thing, you will have to either make your own loop using GET (to
- get a character at a time and parse it as you go), or you can use the MID$
- or RIGHT$ functions to extract pieces of text.
- For example, I enter the command GET KEY (a common text adventure command)
- so, say A$ now contains "GET KEY". To play with that I can :
- B$ = RIGHT$(A$,3) --> B$ now contains "KEY"
- Basically, I believe that you want to determine where a command ends and
- where the parameters kick in (GET being the command and KEY being the
- parameter). So,
-
- 10 X=0:REM INDEX INTO STRING (A$)
- 20 IF MID$(A$,X,1)=" "THEN50
- 30 C$=C$+MID$(A$,X,1):REM ASSEMBLE THE COMMAND
- 40 X=X+1:GOTO20:REM INCREMENT INDEX AND GET NEXT LETTER OF COMMAND
- 50 B$=RIGHT$(A$,LEN(A$)-X):REM PUT THE OBJECT/WHATEVER INTO B$
-
- That should do it (it has been a while since I have done BASIC - I usually
- work in Assembly Language on most of my tasks, since BASIC is a little slow
- for the stuff that I do... By the way, the program assumes that A$ contains
- the complete command (ie. GET KEY) and then it makes C$ the command that
- was typed (GET) and B$ the object (KEY). Note that if you were to enter a
- multi-part command that it would not split it all up - if you entered
- GET THE KEY, c$ would be GET and B$ would be THE KEY.
-
- Whew! Hope that helps...
-
-